/*
 * Copyright [2022] [https://www.xiaonuo.vip]
 *
 * Snowy采用APACHE LICENSE 2.0开源协议，您在使用过程中，需要注意以下几点：
 *
 * 1.请不要删除和修改根目录下的LICENSE文件。
 * 2.请不要删除和修改Snowy源码头部的版权声明。
 * 3.本项目代码可免费商业使用，商业使用请保留源码和相关描述文件的项目出处，作者声明等。
 * 4.分发源码时候，请注明软件出处 https://www.xiaonuo.vip
 * 5.不可二次分发开源参与同类竞品，如有想法可联系团队xiaonuobase@qq.com商议合作。
 * 6.若您的项目无法满足以上几点，需要更多功能代码，获取Snowy商业授权许可，请在官网购买授权，地址为 https://www.xiaonuo.vip
 */
package com.gzx.plugin.tjzy.modular.repaymentQuery.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gzx.plugin.tjzy.core.utils.ExcelUtil;
import com.gzx.plugin.tjzy.modular.repaymentQuery.entity.DataWxjkHksj;
import com.gzx.plugin.tjzy.modular.repaymentQuery.entity.vo.DataWxjkHksjVo;
import com.gzx.plugin.tjzy.modular.repaymentQuery.param.DataWxjkHksjAddParam;
import com.gzx.plugin.tjzy.modular.repaymentQuery.param.DataWxjkHksjEditParam;
import com.gzx.plugin.tjzy.modular.repaymentQuery.param.DataWxjkHksjIdParam;
import com.gzx.plugin.tjzy.modular.repaymentQuery.param.DataWxjkHksjPageParam;
import com.gzx.plugin.tjzy.modular.repaymentQuery.service.DataWxjkHksjService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.pojo.CommonResult;

import java.util.List;

/**
 * 维信金科还款数据控制器
 *
 * @author 刘志刚
 * @date 2024/12/18 09:52
 */
@Tag(name = "维信金科还款数据控制器")
@RestController
@Validated//用于对方法的参数校验
public class DataWxjkHksjController {

    @Resource
    private DataWxjkHksjService dataWxjkHksjService;

    /**
     * 获取维信金科还款数据分页
     *
     * @author 刘志刚
     * @date 2024/12/18 09:52
     */
    @Operation(summary = "获取维信金科还款数据分页")
    @SaCheckPermission("/tjzy/repaymentQuery/page")//权限校验的注解
    @GetMapping("/tjzy/repaymentQuery/page")
    public CommonResult<Page<DataWxjkHksjVo>> page(DataWxjkHksjPageParam dataWxjkHksjPageParam) {
        return CommonResult.data(dataWxjkHksjService.page(dataWxjkHksjPageParam));
    }

    /**
     * 添加维信金科还款数据
     *
     * @author 刘志刚
     * @date 2024/12/18 09:52
     */
    @Operation(summary = "添加维信金科还款数据")
    @CommonLog("添加维信金科还款数据")
    @SaCheckPermission("/tjzy/repaymentQuery/add")
    @PostMapping("/tjzy/repaymentQuery/add")
    public CommonResult<String> add(@RequestBody @Valid DataWxjkHksjAddParam dataWxjkHksjAddParam) {
        dataWxjkHksjService.add(dataWxjkHksjAddParam);
        return CommonResult.ok();
    }

    /**
     * 编辑维信金科还款数据
     *
     * @author 刘志刚
     * @date 2024/12/18 09:52
     */
    @Operation(summary = "编辑维信金科还款数据")
    @CommonLog("编辑维信金科还款数据")
    @SaCheckPermission("/tjzy/repaymentQuery/edit")
    @PostMapping("/tjzy/repaymentQuery/edit")
    public CommonResult<String> edit(@RequestBody @Valid DataWxjkHksjEditParam dataWxjkHksjEditParam) {
        dataWxjkHksjService.edit(dataWxjkHksjEditParam);
        return CommonResult.ok();
    }

    /**
     * 删除维信金科还款数据
     *
     * @author 刘志刚
     * @date 2024/12/18 09:52
     */
    @Operation(summary = "删除维信金科还款数据")
    @CommonLog("删除维信金科还款数据")
    @SaCheckPermission("/tjzy/repaymentQuery/delete")
    @PostMapping("/tjzy/repaymentQuery/delete")
    public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
                                       List<DataWxjkHksjIdParam> dataWxjkHksjIdParamList) {
        dataWxjkHksjService.delete(dataWxjkHksjIdParamList);
        return CommonResult.ok();
    }

    /**
     * 获取维信金科还款数据详情
     *
     * @author 刘志刚
     * @date 2024/12/18 09:52
     */
    @Operation(summary = "获取维信金科还款数据详情")
    @SaCheckPermission("/tjzy/repaymentQuery/detail")
    @GetMapping("/tjzy/repaymentQuery/detail")
    public CommonResult<DataWxjkHksj> detail(@Valid DataWxjkHksjIdParam dataWxjkHksjIdParam) {
        return CommonResult.data(dataWxjkHksjService.detail(dataWxjkHksjIdParam));
    }

    @Operation(summary = "导出维信金科的还款数据")
    @GetMapping("/tjzy/repaymentQuery/export")
    @CommonLog("导出维信金科还款数据")
    public void export(DataWxjkHksjPageParam dataWxjkHksjPageParam, HttpServletResponse response) {
        List<DataWxjkHksjVo> result = dataWxjkHksjService.export(dataWxjkHksjPageParam);
        ExcelUtil.exportExcel(response, DataWxjkHksjVo.class, result);
    }
}
